package com.g001.service;

import org.lwjgl.input.Keyboard;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

import com.g001.enums.CharacterType;
import com.g001.model.Arena;
import com.g001.model.Clouds;
import com.g001.model.Enemy;
import com.g001.model.Entity;
import com.g001.model.GCharacter;
import com.g001.model.Mountains;
import com.g001.model.Player;
import com.g001.service.ligthing.LightningBolts;

public class BattleArenaService {
	
	/*
	g.translate(zoompoint.x, zoompoint.y);
	g.scale(scale,scale)
	g.translate(-zoompoint.x, -zoompoint.y);
	*/
//	private Arena ground;
//	private Entity sky;
//	private Entity moon;
//	private Mountains mountains;
//	private Entity trees;
//	private Clouds clouds;
 
	
	private Player player;
	private Enemy enemy;
	
	private Vector2f position;
	 
	
	LightningBolts lightningBolts;
	
	private float CHARACTER_SPACE = 200;
	
	public void init(GameContainer container, StateBasedGame game) throws SlickException{
		position = new Vector2f(0,600);
 
//		sky = new Entity("sky","data/g001/sky.png",new Vector2f(0,0));
//		moon = new Entity("moon","data/g001/moon.png",new Vector2f(450,0));
//		mountains = new Mountains("mountains","data/g001/mountains.png",new Vector2f(0,250));
//		ground = new Arena("data/g001/ground.png");
//		ground.setPosition(position);
//		clouds = new Clouds("clouds","data/g001/clouds.png",new Vector2f(0,0));
// 		trees = new Entity("trees","data/g001/trees.png",new Vector2f(0,35));
 
		Vector2f playerPosition = new Vector2f(CHARACTER_SPACE/2,500-CharacterType.TILEHEIGHT);
		Vector2f enemyPosition = new Vector2f(container.getWidth()-CHARACTER_SPACE,500-CharacterType.TILEHEIGHT);
		player = new Player(container,CharacterType.ERIC, "You", playerPosition);
		enemy = new Enemy(container,CharacterType.EVIL_ERIC, "Devil you",enemyPosition);
	}
	
	public GCharacter getPlayer(){
		return player;
	}
	
	public GCharacter getEnemy(){
		return enemy;
	}
	
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
//		sky.render(container, game, g);
//		moon.render(container, game, g);
//		clouds.render(container, game, g);
//		mountains.render(container, game, g);
//		g.drawImage(ground.getImage(), ground.getPosition().x , ground.getPosition().y ); 
//		trees.render(container, game, g);
//		
		player.render(container, game, g);
		enemy.render(container, game, g);
		
	}
	
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
//		sky.update(container, game, delta);
//		moon.update(container, game, delta);
//		clouds.update(container, game, delta);
//		mountains.update(container, game, delta);
//		trees.update(container, game, delta);
		player.update(container, game, delta);
		enemy.update(container, game, delta);
		 
//	 
//		if(moon.getPosition().x<=container.getWidth()){
//			moon.setPosition(new Vector2f(moon.getPosition().x+0.0001f*delta,moon.getPosition().y+0.0002f*delta));
//		} 
	}


}
